package com.adam.springbucks.per.entity;

import com.baomidou.mybatisplus.annotation.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.time.LocalDateTime;

/**
 * @ClassName: Person
 * @Author Adam
 * @Date 2022/10/29
 * @Description:
 */
@Data
@ToString
@NoArgsConstructor
@AllArgsConstructor
@TableName("person")
public class Person {

    @TableId(value = "id", type = IdType.AUTO)
    private Long id;
    private String name;
    private Integer age;
    private Double score;

    /**
     * 记录 redis对LocalDateTime类型的序列化会报错
     * 解决方案一在该类型字段上面添加两个注解: 很烦,每个字段都要加,可以定义一个BaseEntity让其他Entity都去继承
     * @JsonDeserialize(using = LocalDateTimeDeserializer.class)
     * @JsonSerialize(using = LocalDateTimeSerializer.class)
     *
     * 解决方案二在配置文件中进行全局配置
     */
//    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
//    @JsonSerialize(using = LocalDateTimeSerializer.class)
//    @JsonFormat( pattern="yyyy-MM-dd HH:mm:ss")
    @TableField(fill = FieldFill.INSERT)
    protected LocalDateTime createTime;

//    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
//    @JsonSerialize(using = LocalDateTimeSerializer.class)
//    @JsonFormat( pattern="yyyy-MM-dd HH:mm:ss")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    protected LocalDateTime updateTime;

    @TableField(select = false)
    protected boolean deleted;
}
